<?php

namespace app\index\controller;

use think\exception\ValidateException;
use app\model\Qrcode;
use app\model\Member;

class QrcodeController extends Base
{

    public function index() {

        $page = input('post.page');
        $goodsid = input('post.goodsid');
        $orderid = input('post.orderid');

        $Qrcode = new Qrcode;

        $Membermob = new Member;
        $memberinfo = $Membermob->getUserByWechat();

        if (!empty($goodsid)) {
            $data = $Qrcode->getGoodsQrcode($goodsid, $memberinfo['id'], $page);
        }elseif (!empty($orderid)) {
            $page = 'pagesA/my/admin/orderDetail';
            $data = $Qrcode->getOrderQrcode($orderid, $page);
        } else {
            $data = $Qrcode->getUserQrcode($memberinfo['id'], $page);
        }
        return $this->json(['data' => $data]);
    }
    public function yuyue() {

        $orderid = input('post.orderid');

        $Qrcode = new Qrcode;
        $page = 'pagesA/my/admin/orderDetail';
        $data = $Qrcode->getOrderQrcode($orderid, $page);
        
        return $this->json(['data' => $data]);
    }
    public function store() {

        $sid = input('post.sid');
        $page = 'pages/store_details/store_details';

        $Qrcode = new Qrcode;
        $Membermob = new Member;
        $memberinfo = $Membermob->getUserByWechat();

        $data = $Qrcode->getStoreQrcode($sid, $memberinfo['id'], $page);

        return $this->json(['data' => $data]);
    }
    public function technical() {

        $id = input('post.id');
        $page = 'pages/technical/details';

        $Qrcode = new Qrcode;
        $Membermob = new Member;
        $memberinfo = $Membermob->getUserByWechat();

        $data = $Qrcode->getStoreQrcode($id, $memberinfo['id'], $page);

        return $this->json(['data' => $data]);
    }
}
